package net.pimpas.web.jsf.managedbean;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import net.pimpas.logging.serviceprovider.LoggingServiceProvider;
import net.pimpas.logging.serviceprovider.LoggingServiceProviderFactoryImpl;
import net.pimpas.operation.exception.OperationException;
import net.pimpas.operation.serviceprovider.OperationServiceProvider;
import net.pimpas.operation.serviceprovider.OperationServiceProviderFactoryImpl;

public class ManagedBeanServletListener implements ServletContextListener {

	public void contextDestroyed(ServletContextEvent arg0) {
		
	}

	public void contextInitialized(ServletContextEvent arg0) {
		OperationServiceProvider op = OperationServiceProviderFactoryImpl.getOperationServiceProvider();
		LoggingServiceProvider logger = LoggingServiceProviderFactoryImpl.getLoggingServiceProvider(ManagedBeanServletListener.class);
		try {
			logger.debug("[ManagedBeanServletListener] - Executing operation ..." );
			op.call("ManagedBeanRuntimeOperation", arg0);
		} catch (OperationException e) {
			logger.fatal(e);
		}
	}
}